package cn.hchaojie.javase.day04;

import org.junit.Test;

public class Test1 {
	public static void main(String[] args) {
		print(1234);
	}

	public static void print(int n) {
		while (n != 0) {
			System.out.print(n % 10);
			n = n / 10;
		}
	}
	
	@Test
	public void testPrintX() {
		// printX(10);
		// printX(3);
		printX(-3);
	}
	
	public static void printX(int n) {
		// 提前处理异常情况，参数不对时，提前返回
		if (n <= 0) {
			return;
		}
		
		if (n >= 20) {
			return;
		}
		
		for (int x = -n; x <= n; x++) {
			for (int y = n; y >= -n; y--) {
				if (Math.abs(x) == Math.abs(y)) {
					System.out.print("* ");
				} else {
					System.out.print("  ");
				}
			}
			System.out.println();
		}
	}
}
